﻿using strange.extensions.command.impl;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;

public class StartCommand : Command
{
    //依赖注入 里面的特性，只有在GameContext.mapBindings()方法里面进行绑定，才可以这样使用
    [Inject]
    public IntegralModel IntegralModel { get; set; }

    [Inject]
    public RoundModel RoundModel { get; set; }

    [Inject]
    public CardModel CardModel { get; set; }

    /// <summary>
    /// 执行事件（发出一条消息，就会执行）
    /// </summary>
    public override void Execute()
    {
        ToolsClass.CreateUIContext(PanelType.StartPanel);

        //初始化model
        IntegralModel.InitIntegration();
        RoundModel.InitRounded();
        CardModel.InitCardLibrary();

        //TODO : 读取数据
        GetGameData();
        //播放音乐
        Sound.Instance.PlayBgMusic(Const.bg_music);

    }

    public void GetGameData()
    {
        FileInfo info = new FileInfo(Const.DataPath);
        if (info.Exists)
        {
            GameDataArgs data = ToolsClass.GetGameData();
            IntegralModel.PlayerIntegration = data.playerIntegration;
            IntegralModel.ComputerLeftIntegration = data.computerLeftIntegration;
            IntegralModel.ComputerRightIntegration = data.computerRightIntegration;

        }

    }
}
